
public class Simply extends Strategy{
	private String password;
	private char actualLetter;
	private int actualLetterIndex;
	private int actualX;
	private int actualY;
		
	public Simply(String pass)
	{
		this.password = pass;
		this.actualLetter = password.charAt(0);
		this.actualLetterIndex = 0;
		this.actualX = 0;
		this.actualY = 0;
	}
	
	public boolean hasNextLetter()
	{
		return password.length() != actualLetterIndex;
	}
	
	@Override
	public CwEntry findEntry(Crossword cw) {
		if ( !hasNextLetter() ) return null;
		String pattern = "^[" + Character.toLowerCase(actualLetter) + Character.toUpperCase(actualLetter) + "].*";
		InteliCwDB cwdb = cw.getCwDB();
		Entry entry = cwdb.getRandom(pattern);
		CwEntry result = new CwEntry(entry,actualX,actualY,Direction.VERT);
		actualX++;
		actualLetterIndex++;
		if ( hasNextLetter() )
			actualLetter = password.charAt(actualLetterIndex);
		return result;
	}

	@Override
	public void updateBoard(Board b, CwEntry e) {
		String word = e.getWord();
		int x = e.getX();
		int y = e.getY();
		for (int i=0; i < word.length(); i++)
		{
			String letter = Character.toString(word.charAt(i));
			b.setCell(x, y+i, new BoardCell(letter));
		}
		
		
	}
	
}
